import com.ethan.pojo.PersonModel;
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;

import java.nio.charset.Charset;

/**
 * @author ethan
 * create 2018-06-12 下午2:41
 * desc
 **/
public class Test {
    public static void main(String[] args) throws InvalidProtocolBufferException {
        PersonModel.Person.Builder builder = PersonModel.Person.newBuilder();
        PersonModel.Person person = builder.setName("zs").setId(1).setEmail("341354345@qq.com").build();

        byte[] bytes = person.toByteArray();
        PersonModel.Person person2 = PersonModel.Person.parseFrom(bytes);

        String str = person.toString();
        byte[] bytes2 = ByteString.copyFrom(str, Charset.defaultCharset()).toByteArray();
        PersonModel.Person person3 = PersonModel.Person.parseFrom(bytes2);

        String a="";
    }
}
